# -*- encoding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
#    $Id$
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from osv import fields
from osv import osv
import wizard
import netsvc
import pooler
import time
from osv.orm import browse_record

class wizard_job_budget_status(wizard.interface):
    def _open_job_budget_status(self, cr, uid, data, context):
        pool_obj = pooler.get_pool(cr.dbname)
        #
        cr.execute("Select\
                        id \
                    from account_analytic_account aaa\
                    where\
                        type='view' and id in (" +','.join(map(str,data['ids']))+")")
        if not cr.rowcount:
            raise osv.except_osv("Warning","This report for Main Project only.")
        else:
            quotation_ids = cr.fetchall()
        value = {
            'domain': "[('project_id', 'in',"+str(quotation_ids)+")]",
            'name': 'Project - Budget Status',
            'view_type': 'form',
            'view_mode': 'tree,form',
            'res_model': 'kdvn.report.job.budget.status',
            'type': 'ir.actions.act_window',
        }
        return value

    states = {
        'init' : {
            'actions' : [],
            'result' : {'type':'action', 'action':_open_job_budget_status, 'state':'end'}
        }
    }
wizard_job_budget_status('project.job.budget.status')